<div class="portlet box green">
 <div class="portlet-title">
     <div class="caption">
         <i class="fa fa-gift"></i>商城基本配置 </div>
     <div class="tools">
         <a href="javascript:;" class="collapse" data-original-title="" title=""> </a>
     </div>
 </div>
 
 <div class="portlet-body form">
     <!-- BEGIN FORM-->
	   <form id="fromSerialize" role="form" action="/platform/modify" class="form-horizontal" method="post" enctype="multipart/form-data">
	        <div class="form-body">
				#foreach($item in $!sysParamList)
				 #set($index = ($velocityCount +(-1)))
				 
				 	#if($!item.sysValueType == "RADIO")
				 	<div class="form-group">
			                <label class="col-md-3 control-label">$!item.display：</label>
			                <div class="col-md-1 control-label">
			                        <input type="radio"  name="list[$!index].value"  value="1" #if($!item.value == '1') checked #end>
			                        <span >是</span>
			                
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		 						<input type="radio"  name="list[$!index].value"  value="0" #if($!item.value == '0') checked #end>
		 						<span>否</span>
		 					</div>
			            </div>
				 
				 	#elseif($!item.sysValueType == "TEXT")
					    <div class="form-group">
			                <label class="col-md-3 control-label">$!item.display：</label>
			                <div class="col-md-4">
			                        <input type="hidden"  name="list[$!index].value"  value="$!item.value" >
			                        <span class="form-control ">$!url$!item.value</span>
			                </div>
							<div class="col-md-5">
		 						<p  class="text-left text-warning form-control-static" >$!item.descs</p>
		 					</div>
			            </div>
	           	 	
					#elseif($!item.sysValueType == "INPUT")
					    <div class="form-group">
			                <label class="col-md-3 control-label">$!item.display：</label>
			                <div class="col-md-4">
			                        <input type="text" class="form-control " name="list[$!index].value"  value="$!item.value" >
			                </div>
							<div class="col-md-5">
		 						<p  class="text-left text-warning form-control-static" >$!item.descs</p>
		 					</div>
			            </div>
	           	 	#elseif($!item.sysValueType == "IMAGE")
			            <div class="form-group">
			                <label class="col-md-3 control-label">$!item.display：</label>
			                <div class="col-md-4">
							<div class="fileinput fileinput-new" data-provides="fileinput">
								<div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
									<img src="$!item.value" >
								</div>
								<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"></div>
								<div>
								    <span class="btn default btn-file">
									    <span class="fileinput-new"> 浏览 </span>
									    <span class="fileinput-exists"> 更改 </span>
									    <input type="file" class="file" name="" accept="image/jpg,image/gif,image/bmp,image/jpeg,image/png">
									    <input type="hidden" name="list[$!index].value" value="$!item.value">
								    </span>
								    <a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput"> 删除 </a>
								</div>
			               	</div>
			                </div>
			            </div>
			            
			            
			        #elseif($!item.sysValueType == "SELECT")   
			             <div class="form-group">
			             	<label class="col-md-3 control-label">$!item.display：</label>
			             	<div class="col-md-3">
			             		<select name="list[$!index].value" class="form-control">
			 						#foreach($sysOption in $!item.getSysOptionMap().entrySet()) 
			 							<option  #if($!item.value==$!sysOption.value) selected #end  value="$!sysOption.value">$!sysOption.key </option>
			 						#end
		 						</select>
		 						<input type="hidden" name="list[$!index].sysOption" value='$!item.sysOption'>
		 					</div>
			             </div>
			           #elseif($!$!item.sysValueType == "FILE")  
			             <div class="form-group">
			                <label class="col-md-3 control-label">$!item.display：</label>
			                <div class="col-md-4">
							<div class="fileinput fileinput-new" data-provides="fileinput">
		 						<p>$!item.descs</p>
								<div class="fileinput-new thumbnail" >
									#if($!item.value)
									<span/>$!item.value</span>
									#else
										<span>未选中文件</span>
									#end
								</div>
								<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"></div>
								<div>
								    <span class="btn default btn-file">
									    <span class="fileinput-new"> 选择文件 </span>
									    <span class="fileinput-exists"> 更改 </span>
									    <input type="file" class="file2" name=""   accept="txt">
									    <input type="hidden" name="list[$!index].value" value="$!item.value">
								    </span>
								    <a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput"> 删除 </a>
								    <span><font color="red">&nbsp;&nbsp;将公众号后台类似 MP_verify_******.txt 的文件上传</font></span>
								</div>
								<div class="col-md-5">
		 					</div>
								
			               	</div>
			                </div>
			            </div>
			           
			           
	          	  	#end
      	  			   <input type="hidden" name="list[$!index].id" value="$!item.id">
                       <input type="hidden" name="list[$!index].code" value="$!item.code">
                       <input type="hidden" name="list[$!index].descs" value="$!item.descs">
                       <input type="hidden" name="list[$!index].sysParamType" value="$!item.sysParamType">
                       <input type="hidden" name="list[$!index].sysValueType" value="$!item.sysValueType">
              		   <input type="hidden" name="list[$!index].display" value="$!item.display">

				#end
	        </div>
		<div class="form-actions right">
	           <div class="row">
	               <div class="col-md-offset-3 col-md-4">
	                   <a class="btn green"  id="submita" >提交</a>
	               </div>
	           </div>
	       </div>
	   </form>
     <!-- END FORM-->
   </div>
</div>
<script type="text/javascript">
/**
 * 上传图片
 */
$(".file").change(function(){
	 var target=$(this);
	 var file = target.context.files[0];
	 var formdata = new FormData();  
	 formdata.append('file',file); 
	 
	 	$.ajax({
		url : '/platform/uploadImg',
		type : 'POST',
		data : formdata,
		async : false,
		cache : false,
		contentType : false,
		processData : false,
		dataType :"JSON",
		success : function(data) {
			target.next().val(data.msg);
		} 
	});
	 	
});

// 上传文件

$(".file2").change(function(){
	 var target=$(this);
	 var file = target.context.files[0];
	 var formdata = new FormData();  
	 formdata.append('file',file); 
	 
	 	$.ajax({
		url : '/platform/uploadFile',
		type : 'POST',
		data : formdata,
		async : false,
		cache : false,
		contentType : false,
		processData : false,
		dataType :"JSON",
		success : function(data) {
			target.next().val(data.msg);
		} 
	});
	 	
});

/**
 * 表单提交
 */
$("#submita").on("click",function(){
  
	
	$.ajax({
		url : '/productSetup/modify',
		type : 'POST',
		data : $("#fromSerialize").serialize(),
 		dataType :"JSON",
		success : function(data) {
			 toastr.success(data.msg);
		},
		error : function(data) {
			 toastr.warning(data.msg);
		}
	});
	
});
</script>